{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-body">
        <form action="{:request()->url()}" class="layui-form" method="post">
            <div class="layui-form-item">
                <label class="layui-form-label">绑定权限</label>
                <div class="layui-input-block">
                    <select name="auth_id">
                        <option value="">请选择权限</option>
                        {foreach name="auth" item="v"}
                        <option value="{$v.id}" {if condition="isset($data) and $data.auth_id eq $v.id or input('auth_id') eq $v.id"}selected="selected"{/if}>{neq name="v.level" value="1"}|{php}for($i=1;$i<$v['level'];$i++){echo ' ----';}{/php}{/neq} {$v.name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">分类名称</label>
                <div class="layui-input-block">
                    <input type="text" name="name" value="{$data.name|default=''}" autocomplete="off" placeholder="请输入名称" lay-verify="required" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item" style="margin-bottom: 14px;">
                <label class="layui-form-label">禁用字段名</label>
                <div class="layui-input-block">
                    <input id="demoTagsInput3" name="disable_field" value="{$data.disable_field|default='id,shop_id,create_time,update_time,delete_time'}"  class="layui-hide"/>
                </div>
            </div>
            <div class="layui-form" lay-filter="freshform">
                <table class="layui-table" lay-filter="test">
                        <thead>
                        <tr>
                            <th style="display: none">序号</th>
                            <th>字段类型</th>
                            <th>字段标题</th>
                            <th>字段标识</th>
                            <th>绑定字典</th>
                            <th>是否系统</th>
                            <th style="text-align: center"><button type="button" class="layui-btn layui-btn-sm add-btn">添加</button></th>
                        </tr>
                        </thead>
                        {if isset($data)}
                        {foreach name="$data.default_field['type']" key="i" item="v"}
                        <tbody>
                            <tr>
                                <td>
                                    <select name="default_field[type][]" lay-verify="required">
                                        <option value="">请选择字段类型</option>
                                        {foreach name=":field_config()" key="k" item="v"}
                                        <option value="{$k}" {if condition="isset($data) and $data.default_field.type[$i] eq $k"}selected="selected"{/if}>{$v}[{$k}]</option>
                                        {/foreach}
                                    </select>
                                </td>
                                <td>
                                    <input type="text"  name="default_field[title][]" value="{$data.default_field.title[$i]|default=''}" class="layui-input" placeholder="" lay-verify="required">
                                </td>
                                <td>
                                    <input type="text" name="default_field[name][]" value="{$data.default_field.name[$i]|default=''}" class="layui-input" placeholder="" lay-verify="required">
                                </td>
                                <td>
                                    <input type="text" name="default_field[value][]" value="{$data.default_field.value[$i]|default=''}" class="layui-input" placeholder="仅字典字段有效">
                                </td>
                                <td>
                                    <select name="default_field[is_sys][]" lay-verify="required">
                                        <option value="">请选择</option>
                                        <option value="0" {if condition="isset($data) and $data.default_field.is_sys[$i] eq 0"}selected="selected"{/if}>否</option>
                                        <option value="1" {if condition="isset($data) and $data.default_field.is_sys[$i] eq 1"}selected="selected"{/if}>是</option>
                                    </select>
                                </td>
                                <td style="text-align: center"><button type="button" class="layui-btn layui-btn-sm layui-btn-danger btn-del" lay-event="del">删除</button></td>
                            </tr>
                        </tbody>
                        {/foreach}
                        {/if}
                        <tbody class="addlists">
                            <tr>
                                <td>
                                    <select name="default_field[type][]" lay-verify="required">
                                        <option value="">请选择字段类型</option>
                                        {foreach name=":field_config()" key="k" item="v"}
                                        <option value="{$k}" {if condition="isset($data) and $data.type eq $k"}selected="selected"{/if}>{$v}[{$k}]</option>
                                        {/foreach}
                                    </select>
                                </td>
                                <td>
                                    <input type="text"  name="default_field[title][]" class="layui-input" placeholder="" lay-verify="required">
                                </td>
                                <td>
                                    <input type="text" name="default_field[name][]" class="layui-input" placeholder="" lay-verify="required">
                                </td>
                                <td>
                                    <input type="text" name="default_field[value][]" class="layui-input" placeholder="请输入字典ID">
                                </td>
                                <td>
                                    <select name="default_field[is_sys][]" lay-verify="required">
                                        <option value="">请选择</option>
                                        <option value="0">否</option>
                                        <option value="1">是</option>
                                    </select>
                                </td>
                                <td style="text-align: center"><button type="button" class="layui-btn layui-btn-sm layui-btn-danger btn-del" lay-event="del">删除</button></td>
                            </tr>
                        </tbody>
                </table>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-filter="i" lay-submit="">保存</button>
                    <button class="layui-btn layui-btn-primary" type="reset">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>
{/block}
{block name="js"}
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/field.js"></script>
<script>
    layui.use(['jquery', 'tagsInput'], function () {
        var $ = layui.jquery;
        var tagsInput = layui.tagsInput;
        // BackSpace键可删除标签
        $('#demoTagsInput3').tagsInput({removeWithBackspace: true});
    });
</script>
{/block}